package com.yehui.spring.aop;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * EnableAspectJAutoProxy 不能和 @Bean 共处一个类, https://segmentfault.com/a/1190000021217176
 *
 * @author 业徽
 * @date 2021/7/1
 */
@EnableAspectJAutoProxy(proxyTargetClass = true)
@Component
public class Main {

    private static final Logger logger = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) throws IOException {
        final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext("com" +
                ".yehui.spring.aop");


        final Main bean = applicationContext.getBean(Main.class);

        logger.info("bean: {}", bean);
        logger.info("class: {}", bean.getClass());

        System.out.println("按任意键退出");
        System.in.read();

        applicationContext.close();
    }

}
